package au.com.langdale.gwt.client.binding;

import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;

import au.com.langdale.gwt.client.binding.BindingManager.Binding;
import au.com.langdale.gwt.client.model.Property;

/**
 * Binds a label to model and property.<p>  
 * 
 * As labels are not editable by the user,
 * this binding transfers the property value
 * to the widget but not visa versa.<p>
 *  
 * @author adv
 *
 */
public class LabelBinding extends Binding {

	private Label label;
	
	public LabelBinding(Object model, Property prop, Label label) {
		super(model, prop);
		this.label = label;
		refresh();
	}

	public void refresh() {
		label.setText(prop.get(model));	
	}
	
	public void destroy() {
		label = null;
	}

	public Widget getWidget() {
		return label;
	}

}
